/* GUI CONVERTED from reoprp40.p (converter v1.76) Thu Mar 14 00:45:27 2002 */
/* reoprp40.p - EMPLOYEE PRODUCTIVITY REPORT                                  */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.11.1.5 $                                                      */
/*V8:ConvertMode=FullGUIReport                                                */
/* REVISION: 7.3      LAST MODIFIED: 10/31/94   BY: WUG *GN77*                */
/* REVISION: 7.3      LAST MODIFIED: 03/01/95   BY: WUG *G0G3*                */
/* REVISION: 7.3      LAST MODIFIED: 03/14/95   By: DZN *G0G8*                */
/* REVISION: 8.6      LAST MODIFIED: 10/22/97   BY: ays *K14J*                */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 06/05/98   BY: *J2NB* A. Licha           */
/* REVISION: 8.6E     LAST MODIFIED: 07/17/98   BY: *L047* Santhosh Nair      */
/* REVISION: 8.6E     LAST MODIFIED: 10/12/98   BY: *L0BY* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Old ECO marker removed, but no ECO header exists *GA37*                    */
/* Revision: 1.11.1.3     BY: Hualin Zhong     DATE: 05/30/01   ECO: *N0YY*   */
/* Revision: 1.11.1.4     BY: Manisha Sawant   DATE: 08/20/01   ECO: *P01N*   */
/* $Revision: 1.11.1.5 $    BY: Amit Chaturvedi  DATE: 03/08/02   ECO: *N1CB*   */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/*V8:DontRefreshTitle=b                                                       */

/* DISPLAY TITLE */

/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE reoprp40_p_1 "Include Nonmilestone Operations"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp40_p_2 "Act Rate"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp40_p_4 "Pcs Proc"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp40_p_5 "Attain %"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp40_p_7 "Prod Hrs"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp40_p_8 "Detail/Summary"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp40_p_9 "Prod %"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp40_p_10 "Down Hrs"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp40_p_13 "Report Format"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp40_p_15 "Std Rate"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp40_p_16 "Util %"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp40_p_18 "Std Run"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp40_p_19 "Std Hrs"
/* MaxLen: Comment: */

&SCOPED-DEFINE reoprp40_p_20 "Tot Hrs"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

define variable emp              like op_emp     no-undo.
define variable emp1             like op_emp     no-undo.
define variable part             like op_part    no-undo.
define variable part1            like op_part    no-undo.
define variable opdate           like op_date    no-undo.
define variable opdate1          like op_date    no-undo.
define variable wkctr            like op_wkctr   no-undo.
define variable wkctr1           like op_wkctr   no-undo.
define variable mach             like op_mch     no-undo.
define variable mach1            like op_mch     no-undo.
define variable run_var          like wr_run     format "->>9.999"      no-undo.
define variable setup_var        like wr_setup   format "->>9.999"      no-undo.
define variable run_eff          like wr_run     format ">>>9.99%"      no-undo.
define variable setup_eff        like run_eff    no-undo.
define variable desc1            like pt_desc1   no-undo.
define variable setup_per        like wr_setup   no-undo.
define variable std_run          like wr_run     label {&reoprp40_p_18} no-undo.
define variable tot_hours        as   decimal    label {&reoprp40_p_20}
                                                 format "->,>>9.9"      no-undo.
define variable std_hours        like tot_hours  label {&reoprp40_p_19} no-undo.
define variable prod_hours       like tot_hours  label {&reoprp40_p_7}  no-undo.
define variable down_hours       like tot_hours  label {&reoprp40_p_10} no-undo.
define variable achvd_rate       as   integer    label {&reoprp40_p_2}
                                                 format "->>>,>>9"      no-undo.
define variable pcs_comp         like achvd_rate label {&reoprp40_p_4}  no-undo.
define variable std_rate         like achvd_rate label {&reoprp40_p_15} no-undo.
define variable shift            like op_shift   no-undo.
define variable detail           like mfc_logical label {&reoprp40_p_13}
                                                 format {&reoprp40_p_8}
                                                 initial yes            no-undo.
define variable include_nonmilestone like mfc_logical
                                                 label {&reoprp40_p_1}  no-undo.
define variable stdhrs           as   decimal    no-undo.
define variable dwn-hours        as   decimal    no-undo.
define variable d-prod-hrs       as   decimal    no-undo.
define variable d-prod-percent   as   decimal    no-undo.
define variable d-util-percent   as   decimal    no-undo.
define variable d-attain-percent as   decimal    no-undo.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
emp       colon 15      emp1      label {t001.i} colon 49
   opdate    colon 15      opdate1   label {t001.i} colon 49
   part      colon 15      part1     label {t001.i} colon 49
   wkctr     colon 15      wkctr1    label {t001.i} colon 49
   mach      colon 15      mach1     label {t001.i} colon 49
   shift     colon 15
   skip (1)
   detail    colon 35
   include_nonmilestone colon 35
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

{wbrp01.i}

/*GUI*/ {mfguirpa.i true "printer" 132 " " " " " "  }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:


   if emp1    = hi_char  then emp1    = "".
   if opdate  = low_date then opdate  = ?.
   if opdate1 = hi_date  then opdate1 = ?.
   if part1   = hi_char  then part1   = "".
   if wkctr1  = hi_char  then wkctr1  = "".
   if mach1   = hi_char  then mach1   = "".

   if c-application-mode <> 'web'
   then
      
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


   /* INCLUDE FILE FOR WEB-ENABLEMENT */
   {wbrp06.i &command = update
             &fields  = "emp emp1 opdate opdate1 part part1 wkctr
                         wkctr1 mach mach1 shift detail
                         include_nonmilestone"
             &frm     = "a"}

   if  (c-application-mode <> 'web')
   or  (c-application-mode =  'web'
   and (c-web-request begins  'data'))
   then do:

      if emp1    = "" then emp1    = hi_char.
      if opdate  = ?  then opdate  = low_date.
      if opdate1 = ?  then opdate1 = hi_date.
      if part1   = "" then part1   = hi_char.
      if wkctr1  = "" then wkctr1  = hi_char.
      if mach1   = "" then mach1   = hi_char.

      bcdparm = "".
      {gprun.i ""gpquote.p""
         "(input-output bcdparm,13,
           emp,emp1,string(opdate),string(opdate1),part,part1,
           wkctr,wkctr1,mach,mach1,shift,string(detail),
           string(include_nonmilestone),
           null_char,null_char,null_char,null_char,
           null_char,null_char,null_char)"}

   end. /* IF c-application-mode <> 'web' */

   /* OUTPUT DESTINATION SELECTION */
   
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i "printer" 132 " " " " " " " " }
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:




   /* TO PRINT PAGE HEADING */
   {mfphead.i}

   if shift > ""
   then do:

      FORM /*GUI*/  header
         getTermLabel("SHIFT",10) + ": " + shift at 61 format "x(14)"
      with STREAM-IO /*GUI*/  frame shift width 132 no-attr-space page-top.
      view frame shift.

   end. /* IF shift > "" */

   for each op_hist
      fields (op_act_run op_act_setup op_date op_emp op_mch op_milestone
              op_part op_qty_comp op_shift op_site op_std_run op_type
              op_wkctr op_wo_lot op_wo_op)
      where (op_emp   >= emp
      and    op_emp   <= emp1)
      and    op_site   = op_site
      and   (op_date  >= opdate
      and    op_date  <= opdate1)
      and   (op_part  >= part
      and    op_part  <= part1)
      and   (op_wkctr >= wkctr
      and    op_wkctr <= wkctr1)
      and   (op_mch   >= mach
      and    op_mch   <= mach1)
      and   (op_shift  = shift
      or     shift     = "")
      and   (op_qty_comp  <> 0
      or     op_act_run   <> 0
      or     op_act_setup <> 0)
      and   (include_nonmilestone
      or     op_milestone)
      and    op_type      <> "DOWN"
      no-lock
      break by op_emp
            by op_date
            by op_part
            by op_wo_op
            by op_wkctr
      with frame b down width 132 no-attr-space:

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame b:handle).

      view frame phead.

      if first-of(op_emp)
      then do:

         if page-size - line-counter < 4
         then
            page.

         display WITH STREAM-IO /*GUI*/ .

         put {gplblfmt.i &FUNC=getTermLabel(""EMPLOYEE"",16)
                         &CONCAT="': '"} op_emp.
         for first emp_mstr
            fields(emp_fname emp_lname)
            where emp_addr = op_emp
            no-lock:
            put emp_fname + " " + emp_lname format "x(33)".
         end. /* FOR FIRST emp_mstr */

         if detail
         then
            put skip.

      end. /* IF FIRST-OF(op_emp) */

      if  first-of(op_date)
      and detail
      then do:

         if page-size - line-counter < 2
         then
            page.

         display WITH STREAM-IO /*GUI*/ .
         put " " {gplblfmt.i &FUNC=getTermLabel(""DATE"",8)
                             &CONCAT="': '"} op_date skip.

      end. /* IF FIRST-OF(op_date) AND detail */

      prod_hours = 0.
      if op_type <> "DOWNTIME"
      then
         prod_hours = op_act_setup + op_act_run.

      down_hours = 0.
      if op_type = "DOWNTIME"
      then
         down_hours = op_act_setup + op_act_run.

      std_hours  = op_std_run * op_qty_comp.

      accumulate op_qty_comp (total by op_wkctr).
      accumulate prod_hours  (total by op_wkctr).
      accumulate down_hours  (total by op_wkctr).
      accumulate std_hours   (total by op_wkctr).

      accumulate prod_hours  (total by op_emp).
      accumulate down_hours  (total by op_emp).
      accumulate std_hours   (total by op_emp).

      if last-of(op_wkctr)
      then do:

         assign
            tot_hours  = (accum sub-total by op_wkctr prod_hours)
                       + (accum sub-total by op_wkctr down_hours)
            pcs_comp   =  accum sub-total by op_wkctr op_qty_comp
            achvd_rate = 0.

         if (accum sub-total by op_wkctr prod_hours) <> 0
         then
            achvd_rate = pcs_comp / (accum sub-total by op_wkctr prod_hours).

         std_rate = 0.
         if (accum sub-total by op_wkctr std_hours) <> 0
         then
            std_rate = pcs_comp / (accum sub-total by op_wkctr std_hours).

         if detail
         then do:

            display op_wo_op WITH STREAM-IO /*GUI*/ .

            for first wr_route
               fields(wr_desc)
               where wr_lot = op_wo_lot
               and   wr_op  = op_wo_op
               no-lock:
            end. /* FOR FIRST wr_route */

            if available wr_route
            then
               display wr_desc format "x(18)" WITH STREAM-IO /*GUI*/ .

            assign
               stdhrs           = (accum sub-total by op_wkctr std_hours)
               dwn-hours        = (accum sub-total by op_wkctr down_hours)
               d-prod-hrs       = (accum sub-total by op_wkctr prod_hours)
               d-prod-percent   = 100 * (accum sub-total by op_wkctr std_hours)
                                / (accum sub-total by op_wkctr prod_hours)
               d-util-percent   = 100 * (accum sub-total by op_wkctr prod_hours)
                                / tot_hours
               d-attain-percent = 100 * (accum sub-total by op_wkctr std_hours)
                                / tot_hours.
            display
               op_wkctr
               pcs_comp
               std_rate
               achvd_rate
               stdhrs           label {&reoprp40_p_19} format "->,>>9.9"
               tot_hours        label {&reoprp40_p_20}
               dwn-hours        label {&reoprp40_p_10} format "->,>>9.9"
               d-prod-hrs       label {&reoprp40_p_7}  format "->,>>9.9"
               d-prod-percent   label {&reoprp40_p_9}  format "->>9.9"
               space(2)
               d-util-percent   label {&reoprp40_p_16} format "->>9.9"
               d-attain-percent label {&reoprp40_p_5}  format "->>9.9 "
            with frame b STREAM-IO /*GUI*/ .

            down 1.
            display op_part @ wr_desc WITH STREAM-IO /*GUI*/ .

         end. /* IF detail */

         accumulate tot_hours (total by op_emp).

      end. /* IF LAST-OF(op_wkctr) */

      if last-of(op_emp)
      then do:

         if page-size - line-counter < 2
         then do:
            page.
            clear frame b.
            display WITH STREAM-IO /*GUI*/ .
         end. /* IF page-size - line-counter < 2 */

         if detail
         then
            put {gplblfmt.i &FUNC=getTermLabel(""EMPLOYEE_TOTAL"",20)
                            &CONCAT="':'"} to 61.
         else
            put {gplblfmt.i &FUNC=getTermLabel(""TOTAL"",20)
                            &CONCAT="':'"} to 61.

            put
            (accum sub-total by op_emp std_hours)  format "->,>>9.9" to 70
            (accum sub-total by op_emp tot_hours)  format "->,>>9.9" to 79
            (accum sub-total by op_emp down_hours) format "->,>>9.9" to 88
            (accum sub-total by op_emp prod_hours) format "->,>>9.9" to 97
            100 * (accum sub-total by op_emp std_hours)
                / (accum sub-total by op_emp prod_hours)
                                                   format "->>9.9%" to 105
            100 * (accum sub-total by op_emp prod_hours)
                / (accum sub-total by op_emp tot_hours)
                                                   format "->>9.9%" to 113
            100 * ((accum sub-total by op_emp std_hours)
                *  (accum sub-total by op_emp prod_hours))
                / ((accum sub-total by op_emp prod_hours)
                *  (accum sub-total by op_emp tot_hours))
                                                   format "->>9.9%" to 121.
      end. /* IF LAST-OF(op_emp) */

      if last (op_emp)
      then do:

         if page-size - line-counter < 2
         then do:
            page.
            clear frame b.
            display WITH STREAM-IO /*GUI*/ .
         end. /* IF page-size - line-counter < 2 */

         put
            skip(1)
            {gplblfmt.i &FUNC=getTermLabel(""REPORT_TOTAL"",20)
                        &CONCAT="':'"} to 61
            (accum total std_hours)  format "->,>>9.9" to 70
            (accum total tot_hours)  format "->,>>9.9" to 79
            (accum total down_hours) format "->,>>9.9" to 88
            (accum total prod_hours) format "->,>>9.9" to 97
            100 * (accum  total std_hours)
                / (accum  total prod_hours)  format "->>9.9%" to 105
            100 * (accum  total prod_hours)
                / (accum  total tot_hours)   format "->>9.9%" to 113
            100 * ((accum total std_hours)
                *  (accum total prod_hours))
                / ((accum total prod_hours)
                *  (accum total tot_hours))  format "->>9.9%" to 121.
      end. /* IF LAST (op_emp) */

      /* REPORT EXIT FOR PAGING INCLUDE FILE */
      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


   end. /* FOR EACH op_hist */

   /* REPORT TRAILER */
   
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


end. /* REPEAT: */

{wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" emp emp1 opdate opdate1 part part1 wkctr wkctr1 mach mach1 shift detail include_nonmilestone "} /*Drive the Report*/
